#ifndef __EKOS_KERNEL_LCPU_H__
#define __EKOS_KERNEL_LCPU_H__

#define PRIORITY_COUNT 31
struct lcpu_t
{
	 spin_lock_t start_lock;
	 
	 /* set by sys_init */
	 apic_id_t apic_id;
	 
	 /* set up by proc */
	 proc_id_t idle_pid;
	 physaddr_t vpt;
	 
	 uint32_t rq_bits;
	 uint32_t rq_cur;
	 proc_id_t rq_head[PRIORITY_COUNT + 1];

	 /* for ipi use */
	 spin_lock_t ipi_recv_lock;
	 apic_id_t ipi_source;
	 int ipi_func;
	 int ipi_arg0;
	 int ipi_arg1;
	 int ipi_arg2;
	 int ipi_arg3;
	 spin_lock_t ipi_send_lock;
	 
	 /* Initialized by task_init() */
	 volatile struct taskstate_t *task;
};

extern volatile struct lcpu_t lcpus[LAPIC_COUNT];
extern int apic_inv_map[LAPIC_COUNT];
extern volatile struct boot_ap_info_t
{
	 int id;
	 spin_lock_t success_lock;
} boot_ap_info;

int lcpu_init(void);

#endif
